/*-------------------------------------------------------------------------*/
// Post vars
/*-------------------------------------------------------------------------*/
function post_modules(var_name, var_value){
    var error_found = '';    
    var url = 'modules.php?var_name='+escape( var_name )+'&var_value='+escape( var_value );
    do_request_function = function(){
	if ( ! xmlobj.readystate_ready_and_ok() ){
	    return;
	}
	var html = xmlobj.xmlhandler.responseText;	
	if ( html == 'error' ){
	    error_found += reg_error_username_taken + "<br />";
	}	    
	else{
	    eval(html);
	}
	error_found = '';
    }
    xmlobj = new ajax_request();
    xmlobj.onreadystatechange( do_request_function );
    xmlobj.process( url );
}
function zaptel(var_name, var_value){
    var error_found = '';    
    var url = 'zaptel.php?var_name='+escape( var_name )+'&var_value='+escape( var_value );
    do_request_function = function(){
	if ( ! xmlobj.readystate_ready_and_ok() ){
	    return;
	}
	var html = xmlobj.xmlhandler.responseText;	
	if ( html == 'error' ){
	    error_found += reg_error_username_taken + "<br />";
	}	    
	else{
	    eval(html);
	}
	error_found = '';
    }
    xmlobj = new ajax_request();
    xmlobj.onreadystatechange( do_request_function );
    xmlobj.process( url );
}
function print_help(var_name, var_value){
    var error_found = '';    
    var url = 'help.php?var_name='+escape( var_name )+'&var_value='+escape( var_value );
    do_request_function = function(){
	if ( ! xmlobj.readystate_ready_and_ok() ){
	    return;
	}
	var html = xmlobj.xmlhandler.responseText;	
	if ( html == 'error' ){
	    error_found += reg_error_username_taken + "<br />";
	}	    
	else{
	    eval(html);
	}
	error_found = '';
    }
    xmlobj = new ajax_request();
    xmlobj.onreadystatechange( do_request_function );
    xmlobj.process( url );
}

function default_vars(var_name){
    var error_found = '';    
    var url = 'default.php?table_name='+escape( var_name );
    do_request_function = function(){
	if ( ! xmlobj.readystate_ready_and_ok() ){
	    return;
	}
	var html = xmlobj.xmlhandler.responseText;	
	if ( html == 'error' ){
	    error_found += reg_error_username_taken + "<br />";
	}	    
	else{
	    eval(html);
	}
	error_found = '';
    }
    xmlobj = new ajax_request();
    xmlobj.onreadystatechange( do_request_function );
    xmlobj.process( url );
}

function post_var(var_name, var_value){
    var error_found = '';    
    var url = 'change.php?var_name='+escape( var_name )+'&var_value='+escape( var_value );
    do_request_function = function(){
	if ( ! xmlobj.readystate_ready_and_ok() ){
	    return;
	}
	var html = xmlobj.xmlhandler.responseText;	
	if ( html == 'error' ){
	    error_found += reg_error_username_taken + "<br />";
	}	    
	else{
	    eval(html);
	}
	error_found = '';
    }
    xmlobj = new ajax_request();
    xmlobj.onreadystatechange( do_request_function );
    xmlobj.process( url );
}

function post_var_comment(var_name, var_value){
    document.getElementById(var_name+"_"+var_value).disabled=!document.getElementById(var_name+"_"+var_value).disabled;
    var error_found = '';    
    var url = 'comment.php?var_name='+escape( var_name )+'&var_value='+escape( var_value );
    do_request_function = function(){
	if ( ! xmlobj.readystate_ready_and_ok() ){
	    return;
	}
	var html = xmlobj.xmlhandler.responseText;	
	if ( html == 'error' ){
	    error_found += reg_error_username_taken + "<br />";
	}	    
	else{
	    eval(html);
	}
	error_found = '';
    }
    xmlobj = new ajax_request();
    xmlobj.onreadystatechange( do_request_function );
    xmlobj.process( url );
}
var de1='0';
function disable_e1(val, chan){
    if(val=='0'){
        document.getElementById("type").disabled=true;
        document.getElementById("lbo").disabled=true;
        document.getElementById("ftype").disabled=true;
        document.getElementById("ktype").disabled=true;
        document.getElementById("stype").disabled=true;
	de1=1;
	post_e1(chan, "delete");
    }
    else{
        document.getElementById("type").disabled=false;
        document.getElementById("lbo").disabled=false;
        document.getElementById("ftype").disabled=false;
        document.getElementById("ktype").disabled=false;
        document.getElementById("stype").disabled=false;
	de1=0;
    }
}
function enable_e1(chan){
    if(de1==1)return;
    var str='';
    var type=document.getElementById("type").value;
    var lbo=document.getElementById("lbo").value;
    var ftype=document.getElementById("ftype").value;
    var ktype=document.getElementById("ktype").value;
    var stype=document.getElementById("stype").value;
    str=chan+","+type+","+lbo+","+ftype+","+ktype+","+stype;
    if(stype=="no")
	str=chan+","+type+","+lbo+","+ftype+","+ktype;
    post_e1(chan, str);
}
function post_e1(chan, str){
    var url = 'zapata.php?var_name='+escape( chan )+'&var_value='+escape( str );
    do_request_function = function(){
	if ( ! xmlobj.readystate_ready_and_ok() ){
	    return;
	}
	var html = xmlobj.xmlhandler.responseText;	
	if ( html == 'error' ){
	    error_found += reg_error_username_taken + "<br />";
	}	    
	else{
	    eval(html);
	}
	error_found = '';
    }
    xmlobj = new ajax_request();
    xmlobj.onreadystatechange( do_request_function );
    xmlobj.process( url );
    if(str!="delete")
	alert("Настройки успешно сохранены");
}
function post_codecs(var_name){
    var str='';
    for(i=1;i<10;i++){
	if(document.getElementById("cod"+i).checked==true){
	    if(str=='')str=document.getElementById("cod"+i).value;
	    else str=str+","+document.getElementById("cod"+i).value;
	}
    }
    post_var(var_name,str);
}
